home *** CD-ROM | disk | FTP | other *** search
/ Day Cry / Day Cry CD.bin / oh_towns / taropyon / splib / splib.lzh / PRG / LHX / ERROR.C < prev    next >
C/C++ Source or Header  |  1992-12-08  |  2KB  |  96 lines

  1. /***********************************************************
  2.         error.c -- error processing
  3. ***********************************************************/
  4. #include    "lh386.h"
  5.  
  6. #include    <fslib.h>
  7.  
  8. #include    <stdio.h>
  9. #include    <stdlib.h>
  10. #include    <signal.h>
  11. #include    "lh.h"
  12. #include    "errmes.h"
  13.  
  14. #ifdef    __HIGHC__
  15. #    pragma    On(Align_labels);
  16. #endif
  17.  
  18. /*    :*****************************************************************
  19.     :    process for error
  20.     :*****************************************************************
  21. */
  22. void        error(char *errmes, char *p)
  23. {
  24.  
  25.     if ( errmes == COPYERR )
  26.     {                            /* error during copying temporary? */
  27.         LHX_printf( "\n%s\n", COPYERR );
  28.         FS_fclose( file1 );
  29.         FS_remove(arcname);        /* erase incomplete archive */
  30.         file1 = NULL;
  31.     } else
  32.         LHX_printf( "\n%s", errmes);
  33.     if ( p )
  34.     {
  35.         LHX_printf( " : '%s'", p );
  36.     }
  37.     LHX_puts( "\n");
  38.     if (file3 != NULL)
  39.     {
  40.         FS_fclose(file3);
  41.         if (cmd == 'E')         /* during extracting */
  42.             FS_remove(filename3);    /* delete the file */
  43.     }
  44.     if (file1 != NULL)
  45.     {
  46.         FS_fclose(file1);
  47.         if (cmdupdate)            /* during updating */
  48.             FS_rename(filename1, arcname); /* recover old archive */
  49.     }
  50.     if (file2 != NULL)
  51.     {
  52.         FS_fclose(file2);
  53.         if (errmes != COPYERR)
  54.         {                        /* if not copying */
  55.             FS_remove(filename2);    /* delete temporary */
  56.         }
  57.     }
  58. END_EXIT:
  59.  
  60.     if (errmes == COPYERR)
  61.         MAIN_EXIT(3);
  62.     else
  63.         MAIN_EXIT(2);
  64. }
  65.  
  66. void        fileerror(char *err, FILE * file)
  67. {
  68.     char       *name;
  69.  
  70.     name = NULL;
  71.     if (file == file1)
  72.         name = filename1;
  73.     if (file == file2)
  74.         name = filename2;
  75.     if (file == file3)
  76.         name = hpb.pathname;
  77.     error(err, name);
  78. }
  79.  
  80. /*******************************
  81.         handle user break
  82. *******************************/
  83. void        userbreak(int code)
  84. {
  85.     code = code;
  86.  
  87.     error(CTRLBRK, NULL);
  88. }
  89.  
  90. void        initbreak(void)
  91. {
  92. #ifndef __HIGHC__
  93.     signal(SIGINT, userbreak);
  94. #endif
  95. }
  96.